import Home from "../view/home"
import Dian from "../view/dian"
import My from "../view/my"
import Search from "../view/search"
import History from "../view/history"
import { Component } from "react"

 import { createBrowserRouter, Route, Routes, useLocation, useRoutes } from "react-router-dom"

//  function Gird(App) {
//     return class GridComponent extends Component {
//         state={}
//       static getDerivedStateFromProps(props){
//         console.log(props)
//         return true
//       }
//       render() {
//         return <App {...this.props} />;
//       }
//     };
//   }
 function RouterView(){
   // 第一种
    // let element=useRoutes([
    //     {path:'/',element:<Home></Home>},
    //     {path:'/dian',element:<Dian></Dian>},
    //     {path:'/my',element:<My></My>},
    // ])
    // return element


//     //第二种
// //    return(
// //     <Routes>
// //         <Route path='/' element={<Home></Home>}></Route>
// //         <Route path='/dian' element={<Dian></Dian>}></Route>
// //         <Route path='/my' element={<My></My>}></Route>
// //     </Routes>
// //    ) 
 
//第三种

const routes=createBrowserRouter([
    {path:'/',element:<Home/>},
    {path:'/dian',element:<Dian></Dian>,handle:{title:'点餐'},
      children:[{path:'search',element:<Search></Search>,handle:{title:'搜索'},children:[{path:'history',element:<History></History>,handle:{title:'历史'}}]}]},
    {path:'/my',element:<My></My>},
])
   return routes

 }

 export default RouterView



